package com.lakeworks.service.impl;


import com.lakeworks.common.core.text.Convert;
import com.lakeworks.common.domain.ticket.TktNode;
import com.lakeworks.mapper.TktNodeMapper;
import com.lakeworks.service.ITktNodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 流程节点定义Service业务层处理
 *
 * @author lake
 * @date 2023-07-17
 */
@Service
public class TktNodeServiceImpl implements ITktNodeService {
    @Autowired
    private TktNodeMapper tktNodeMapper;

    /**
     * 查询流程节点定义
     *
     * @param id 流程节点定义主键
     * @return 流程节点定义
     */
    @Override
    public TktNode selectTktNodeById(Long id) {
        return tktNodeMapper.selectTktNodeById(id);
    }

    /**
     * 查询流程节点定义列表
     *
     * @param tktNode 流程节点定义
     * @return 流程节点定义
     */
    @Override
    public List<TktNode> selectTktNodeList(TktNode tktNode) {
        return tktNodeMapper.selectTktNodeList(tktNode);
    }

    /**
     * 新增流程节点定义
     *
     * @param tktNode 流程节点定义
     * @return 结果
     */
    @Override
    public int insertTktNode(TktNode tktNode) {
        return tktNodeMapper.insertTktNode(tktNode);
    }

    /**
     * 修改流程节点定义
     *
     * @param tktNode 流程节点定义
     * @return 结果
     */
    @Override
    public int updateTktNode(TktNode tktNode) {
        return tktNodeMapper.updateTktNode(tktNode);
    }

    /**
     * 批量删除流程节点定义
     *
     * @param ids 需要删除的流程节点定义主键
     * @return 结果
     */
    @Override
    public int deleteTktNodeByIds(String ids) {
        return tktNodeMapper.deleteTktNodeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除流程节点定义信息
     *
     * @param id 流程节点定义主键
     * @return 结果
     */
    @Override
    public int deleteTktNodeById(Long id) {
        return tktNodeMapper.deleteTktNodeById(id);
    }

    @Override
    public Long getNodeId(long flowId, int no) {
        return tktNodeMapper.selectNodeIdbyNo(TktNode.builder().flowId(flowId).no(no).build());
    }
}
